package com.liuyfly.leetcode.study;

/**
 * @author liuyangfang at 2022-08-29 01:31
 */
public class DiagonalTraverse {

    public int[] findDiagonalOrder(int[][] mat) {
        if (mat.length==0||mat[0].length==0){
            return null;
        }
        int[] array = new int[mat.length*mat[0].length];
        boolean flag = false;
        array[0]=mat[0][0];
        array[1]=mat[0][1];
        for (int i=0;i<mat.length;){
            for (int j=1;j<mat[i].length;){
                if (j==0&&!flag){
                    flag=true;
                    i++;
                }
                if (i==0&&flag) {
                    flag =false;
                    j--;
                }
                if (!flag){
                    i++;j--;
                } else {
                    i--;j++;
                }

            }
        }
        return array;
    }

    public static void main(String[] args) {

    }
}
